﻿using System.Linq;
using Core.Interfaces;
using Core.Model;
using Infrastructure.Database;

namespace Infrastructure.Repositories
{
    public class AccountRepository : IAccountRepository
    {

        public Account RetrieveAccount(string userId)
        {
            using (var ctx = new PetshopDbContext())
            {
                return ctx.Accounts.SingleOrDefault(c => c.UserId == userId);
            }
        }


        public bool ValidateUser(string userId, string password)
        {
            using (var ctx = new PetshopDbContext())
            {
                return ctx.Accounts.SingleOrDefault(c => c.UserId == userId && c.Password == password) != null;
            }
        }
    }
}
